package cate.game.activity.commonstarup.msg;


import cate.common.table.d.GDFunc;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.commonstarup.CommonStarUpGiftActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBCommonStarUpActivity;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "升星豪礼-购买 请求")
public class CommonStarUpGiftBuyReq implements MsgInput {
    @NoteField("功能ID")
    public int funcId;
    @NoteField("英雄ID")
    public int tid;
    @NoteField("数量")
    public int num;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        CommonStarUpGiftActivity single = cc.getRole().getActivity().getEnableActivitySingle(GDFunc.COMMON_STAR_UP);
        if (single == null) {
            return;
        }
        GameResult<CommonStarUpGiftActivity> r = single.buyItem(tid,num);
        if (r.ok()) {
            r.data.noticeUpdate();
        } else {
            game.notice.message(cc.getRole(), r.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBCommonStarUpActivity.COMMON_STAR_UP_GIFT_BUY_REQ;
    }
}
